import React from 'react'
import { Link } from 'react-router-dom'

export default function Home({ location }) {
  //没有传递用户数据
  if (!location.state) {
    return (
      <h1 style={{ fontSize: 30 }}>
        请进行<Link to="/login/code">登录</Link>
      </h1>
    )
  }

  return (
    <div>
      <h1>{location.state.username}</h1>
      <img src={location.state.avatar} alt="图片" />
    </div>
  )
}
